/*Source

Problem Id:2692  User Id:Latex 
Memory:280K  Time:15MS
Language:G++  Result:Accepted

Source 
*/
#include <stdio.h>
#include <string.h>

int score[50];
char name[50][400];
int choose[2000][50];
int fout[50];
int maxv, minv, maxs, mins;
int n, m, win;

int main()
{
	int i, j;
	
//	freopen("j.in","r",stdin);
//	freopen("j.out","w",stdout);
	
//	while (scanf("%d", &n)!=EOF)
	scanf("%d", &n);
	{

		memset(fout, 0, sizeof(fout));
		for (i=0; i<=n; ++i)
			gets(name[i]);
			
		/*/check:
		for (i=1; i<=n; ++i)
			printf("%s\n", name[i]);
		printf("end of checking..\n");*/
			
//		scanf("%d", &m);
		m = 1;
		while (scanf("%d", &choose[m][1])!=EOF)
		{
			choose[m][0] = 1;
			for (j=2; j<=n; ++j)
				scanf("%d", &choose[m][j]);
			m++;
		}	
		m--;
		win = m/2;
		
		while (1)
		{
			memset(score, 0, sizeof(score));
			for (i=1; i<=m; ++i)
			{
				while (fout[ choose[i][ choose[i][0] ] ] == 1 && choose[i][0]<=n) choose[i][0]++;
				score[choose[i][ choose[i][0] ]]++;
			}
			for (i=1; i<=n; ++i) 
				if (fout[i]==0) break;
				
			maxv = minv = score[i];
			maxs = mins = i;
			for (i=1; i<=n; ++i)
			{
				if (fout[i]==0)
				{
					if (maxv < score[i]) maxv = score[i], maxs = i;
					if (minv > score[i]) minv = score[i], mins = i;
				}
			}
			if (maxv == minv)
			{
				for (i=1; i<=n; ++i)
					if (score[i] == maxv && fout[i]==0)
						printf("%s\n", name[i]);
				break;
			}
			else if (maxv > win)
			{
				printf("%s\n", name[maxs]);
				break;
			}
			else
			{
				for (i=1; i<=n; ++i)
					if (score[i] == minv)
						fout[i] = 1;
			}
		}
		
		
	}
	
	

	return 0;	
}



